package operator.function;

import io.reactivex.Observable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Timed;
import util.Printer;

class TimestampOperator {

    public static void main(String[] args) {
        timestamp();
    }

    /**
     * 每一个元素打上时间戳
     */
    static void timestamp(){
        Observable.just(1, 2, 3)
                .timestamp()
//                .timestamp(TimeUnit.SECONDS)
                .subscribe(new Consumer<Timed<Integer>>() {
                    @Override
                    public void accept(Timed<Integer> integerTimed) throws Exception {
                        Printer.print("onNext integerTimed = " + integerTimed);
                    }
                });
    }


}
